package com.lollipop.mybaitsplus.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.lollipop.mybaitsplus.utils.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author: J.K
 * @Date: 2021-09-18 13:50
 * @Description:
 */
public class CustomIdGenerator implements IdentifierGenerator {
    @Autowired
    private SnowflakeIdUtils snowflakeIdUtils;

    /**
     * 生成Id
     *
     * @param entity 实体
     * @return id
     */
    @Override
    public Number nextId(Object entity) {
        return snowflakeIdUtils.nextId();
    }
}
